import 'package:freezed_annotation/freezed_annotation.dart';

part 'goods_details_model.freezed.dart';

part 'goods_details_model.g.dart';

@freezed
class GoodsDetailsModel with _$GoodsDetailsModel {
  const factory GoodsDetailsModel({
    required int discount,
    required String desc,
    required String id,
    required int inventory,
    required bool isPreSale,
    required String name,
    required String oldPrice,
    required String price,
    required String spuCode,
    required int videoScale,
    required GoodsDetailsBrandModel? brand,
    required GoodsDetailsDetailsModel details,
    required GoodsDetailsEvaluationInfoModel evaluationInfo,
    required List<String> mainPictures,
    @Default([]) List<GoodsDetailsHotByDay> hotByDay,
    @Default([]) List<GoodsDetailsRecommendsModel> recommends,
    @Default([]) List<GoodsDetailsSimilarProductsModel> similarProducts,
    @Default([]) List<GoodsDetailsSkusModel> skus,
    @Default([]) List<GoodsDetailsSpecs2Model> specs,
    @Default([]) List<GoodsDetailsUserAddressModel> userAddresses,
  }) = _GoodsDetailsModel;

  factory GoodsDetailsModel.fromJson(Map<String, dynamic> json) =>
      _$GoodsDetailsModelFromJson(json);
}

@freezed
class GoodsDetailsBrandModel with _$GoodsDetailsBrandModel {
  const factory GoodsDetailsBrandModel({
    required String id,
    required String logo,
    required String name,
    required String nameEn,
    required String picture,
  }) = _GoodsDetailsBrandModel;

  factory GoodsDetailsBrandModel.fromJson(Map<String, dynamic> json) =>
      _$GoodsDetailsBrandModelFromJson(json);
}

@freezed
class GoodsDetailsDetailsModel with _$GoodsDetailsDetailsModel {
  const factory GoodsDetailsDetailsModel({
    @Default([]) List<String> pictures,
    @Default([]) List<GoodsDetailsDetailspropertiesModel> properties,
  }) = _GoodsDetailsDetailsModel;

  factory GoodsDetailsDetailsModel.fromJson(Map<String, dynamic> json) =>
      _$GoodsDetailsDetailsModelFromJson(json);
}

@freezed
class GoodsDetailsDetailspropertiesModel with _$GoodsDetailsDetailspropertiesModel {
  const factory GoodsDetailsDetailspropertiesModel({
    required String name,
    required String value,
  }) = _GoodsDetailsDetailspropertiesModel;

  factory GoodsDetailsDetailspropertiesModel.fromJson(Map<String, dynamic> json) =>
      _$GoodsDetailsDetailspropertiesModelFromJson(json);
}

@freezed
class GoodsDetailsEvaluationInfoModel with _$GoodsDetailsEvaluationInfoModel {
  const factory GoodsDetailsEvaluationInfoModel({
    required String content,
    required String createTime,
    required String id,
    required String officialReply,
    required int praiseCount,
    required int praisePercent,
    required int score,
    required MemberModel member,
    required OrderInfoModel orderInfo,
    @Default([]) List<String> pictures,
    @Default([]) List<String> tags,
  }) = _GoodsDetailsEvaluationInfoModel;

  factory GoodsDetailsEvaluationInfoModel.fromJson(Map<String, dynamic> json) =>
      _$GoodsDetailsEvaluationInfoModelFromJson(json);
}

@freezed
class MemberModel with _$MemberModel {
  const factory MemberModel({
    required String account,
    required String avatar,
    required String id,
  }) = _MemberModel;

  factory MemberModel.fromJson(Map<String, dynamic> json) => _$MemberModelFromJson(json);
}

@freezed
class OrderInfoModel with _$OrderInfoModel {
  const factory OrderInfoModel({
    required String createTime,
    required int quantity,
    @Default([]) List<SpecsModel> specs,
  }) = _OrderInfoModel;

  factory OrderInfoModel.fromJson(Map<String, dynamic> json) => _$OrderInfoModelFromJson(json);
}

@freezed
class SpecsModel with _$SpecsModel {
  const factory SpecsModel({
    required String name,
    required String valueName,
  }) = _SpecsModel;

  factory SpecsModel.fromJson(Map<String, dynamic> json) => _$SpecsModelFromJson(json);
}

@freezed
class GoodsDetailsHotByDay with _$GoodsDetailsHotByDay {
  const factory GoodsDetailsHotByDay({
    required String desc,
    required String id,
    required String name,
    required int orderNum,
    required String picture,
    required String price,
  }) = _GoodsDetailsHotByDay;

  factory GoodsDetailsHotByDay.fromJson(Map<String, dynamic> json) =>
      _$GoodsDetailsHotByDayFromJson(json);
}

@freezed
class GoodsDetailsRecommendsModel with _$GoodsDetailsRecommendsModel {
  const factory GoodsDetailsRecommendsModel({
    required String id,
    required String name,
    required String desc,
    required int orderNum,
    required String picture,
    required String price,
  }) = _GoodsDetailsRecommendsModel;

  factory GoodsDetailsRecommendsModel.fromJson(Map<String, dynamic> json) =>
      _$GoodsDetailsRecommendsModelFromJson(json);
}

@freezed
class GoodsDetailsSimilarProductsModel with _$GoodsDetailsSimilarProductsModel {
  const factory GoodsDetailsSimilarProductsModel({
    required String id,
    required String name,
    required String desc,
    required int orderNum,
    required String picture,
    required String price,
  }) = _GoodsDetailsSimilarProductsModel;

  factory GoodsDetailsSimilarProductsModel.fromJson(Map<String, dynamic> json) =>
      _$GoodsDetailsSimilarProductsModelFromJson(json);
}

@freezed
class GoodsDetailsSkusModel with _$GoodsDetailsSkusModel {
  const factory GoodsDetailsSkusModel({
    required String id,
    required String oldPrice,
    required String picture,
    required String price,
    required String skuCode,
    required int inventory,
    @Default([]) List<GoodsDetailsSkusSpecsModel> specs,
  }) = _GoodsDetailsSkusModel;

  factory GoodsDetailsSkusModel.fromJson(Map<String, dynamic> json) =>
      _$GoodsDetailsSkusModelFromJson(json);
}

@freezed
class GoodsDetailsSkusSpecsModel with _$GoodsDetailsSkusSpecsModel {
  const factory GoodsDetailsSkusSpecsModel({
    required String name,
    required String valueName,
  }) = _GoodsDetailsSkusSpecsModel;

  factory GoodsDetailsSkusSpecsModel.fromJson(json) => _$GoodsDetailsSkusSpecsModelFromJson(json);
}

@freezed
class GoodsDetailsSpecs2Model with _$GoodsDetailsSpecs2Model {
  const factory GoodsDetailsSpecs2Model({
    required String id,
    required String name,
    @Default([]) List<GoodsDetailsSpecsValuesModel> values,
  }) = _GoodsDetailsSpecs2Model;

  factory GoodsDetailsSpecs2Model.fromJson(Map<String, dynamic> json) =>
      _$GoodsDetailsSpecs2ModelFromJson(json);
}

@freezed
class GoodsDetailsSpecsValuesModel with _$GoodsDetailsSpecsValuesModel {
  const factory GoodsDetailsSpecsValuesModel({
    required String desc,
    required String name,
    required String? picture,
    @Default(false) bool isSelected,
    @Default(false) bool disable,
  }) = _GoodsDetailsSpecsValuesModel;

  factory GoodsDetailsSpecsValuesModel.fromJson(json) =>
      _$GoodsDetailsSpecsValuesModelFromJson(json);
}

@freezed
class GoodsDetailsUserAddressModel with _$GoodsDetailsUserAddressModel {
  const factory GoodsDetailsUserAddressModel({
    required String address,
    required String addressTags,
    required String cityCode,
    required String contact,
    required String countyCode,
    required String fullLocation,
    required String id,
    required int isDefault,
    required String postalCode,
    required String provinceCode,
    required String receiver,
  }) = _GoodsDetailsUserAddressModel;

  factory GoodsDetailsUserAddressModel.fromJson(json) =>
      _$GoodsDetailsUserAddressModelFromJson(json);
}
